package com.lazy.book.service.system;

import com.lazy.book.common.enums.CommonResponseEnum;
import com.lazy.book.common.pojp.LoginInfo;
import com.lazy.book.common.pojp.LoginVO;
import com.lazy.book.common.utils.SpringApplicationContextUtils;
import com.lazy.book.common.entity.ClientVO;

/**
 *
 * @author lazy
 * @since 2025-09-04
 */
public interface IAuthStrategy {
  String BASE_NAME = "AuthStrategy";

  static LoginVO login(LoginInfo info, ClientVO client, String grantType) {
    // 授权类型和客户端id
    String beanName = grantType + BASE_NAME;
    CommonResponseEnum.INVALID.message("无效的授权类型").assertFalse(SpringApplicationContextUtils.getInstance().containsBean(beanName));
    IAuthStrategy instance = SpringApplicationContextUtils.getInstance().getBean(beanName);
    return instance.login(info, client);
  }

  LoginVO login(LoginInfo info, ClientVO client);
}
